﻿<%@ Page Title="" Language="C#" MasterPageFile="~/EasyUI.Master" AutoEventWireup="true" CodeBehind="Listinfo.aspx.cs" Inherits="lcgps.Web.gpsinfo.Listinfo" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">    
    <script type="text/javascript">
        $(function () {
            InitGird();
        });
        //初始化表格
        function InitGird() {
            $('#tt').datagrid({
                title: '运送车辆列表', //表格标题
                url: 'GetGPS.ashx', //请求数据的页面
                sortName: 'gdatetime', //排序字段
                idField: '', //标识字段,主键
                iconCls: '', //标题左边的图标
                width: '100%', //宽度
                //height: $(parent.document).find("#mainPanle").height() - 35 > 0 ? $(parent.document).find("#mainPanle").height() - 35 : 500, //高度
                nowrap: false, //是否换行，True 就会把数据显示在一行里
                striped: true, //True 奇偶行使用不同背景色
                collapsible: false, //可折叠
                singleSelect: true,
                sortOrder: 'desc', //排序类型
                remoteSort: true, //定义是否从服务器给数据排序
                fitColumns: true,
                method: 'post',
                columns: [[
                    { field: 'ckb', checkbox: true },
                    { title: '项目号', field: 'proid', width: 150 },
                { title: '订单号', field: 'purchaseid', width: 150 },
        { title: '物料号', field: 'mid', width: 150 },
        {
            title: '最后时间', field: 'gdatetime', width: 200            
        }

                ]],
                toolbar: "#tab_toolbar",
                queryParams: { "action": "queryone" },
                pagination: true, //是否开启分页
                pageNumber: 1, //默认索引页
                pageSize: 20, //默认一页数据条数
                rownumbers: true //行号
            });
        }
        function getQueryParams(queryParams) {
            var StartTime = $("#StartTime").datebox("getValue");
            var EndTime = $("#EndTime").datebox("getValue");
            var pid = $("#pid").val();
            var pcid = $("#pcid").val();
            var mid = $("#mid").val();
            queryParams.StartTime = StartTime;
            queryParams.EndTime = EndTime;
            queryParams.pid = pid;
            queryParams.pcid = pcid;
            queryParams.mid = mid;
            return queryParams;
        }

        //增加查询参数，重新加载表格  
        function reloadgrid() {
            var queryParams = $('#tt').datagrid('options').queryParams;
            getQueryParams(queryParams);
            $('#tt').datagrid('options').queryParams = queryParams;
            $("#tt").datagrid('reload');
        }
        function removeUser() {
            var row = $('#tt').datagrid('getSelected');
            if (row == null) {
                $.messager.alert("提示", "请选择要删除的行！", "info");
            }
            if (row) {
                $.messager.confirm('提示', '你确定要删除这条信息吗？', function (r) {
                    if (r) {
                        $('#fm').form('submit', {
                            url: 'GetGPS.ashx?pid=' + row.proid + '&pcid=' + row.purchaseid + '&mid=' + row.mid + '&action=delete',
                            onSubmit: function () {
                                //return $(this).form('validate');  
                            },
                            success: function (result) {
                                if (result.indexOf("T") == 0) {
                                    $('#dlg').dialog('close');
                                    $('#tt').datagrid('clearSelections'); //清空选中的行  
                                    $.messager.alert("提示", "恭喜您，信息删除成功！", "info");                                    
                                    $('#tt').datagrid('reload');

                                }
                                else if ((result.indexOf("F") == 0)) {
                                    $.messager.alert("提示", "删除失败，请重新操作！", "info");
                                    return;
                                }
                                else if ((result.indexOf("L") == 0)) {
                                    $.messager.alert("提示", "长时间没有操作，请重新登录！", "info");
                                    top.location = '/index.aspx';
                                    return;
                                }
                            }
                        });
                    }
                })
            }
        }

    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <table id="tt">
    </table>
    <div id="tab_toolbar" style="padding: 4px;">
        <table cellpadding="0" cellspacing="0" style="width: 100%">
            <tr>

                <td style="padding-left: 2px">
                    <a href="#" onclick="removeUser();return false;" id="a_del" class="easyui-linkbutton" iconcls="icon-cancel">删除</a>
                </td>
                <td style="text-align: right; padding-right: 15px">时间从:  
           <input id="StartTime" class="easyui-datebox" style="width: 100px" />
                    到:  
           <input id="EndTime" class="easyui-datebox" style="width: 100px" />
                    项目编号：<input type="text" id="proid" name="proid" />
                    订单号：<input type="text" id="pcid" name="pcid" />
                    物料号：<input type="text" id="mid" name="mid" />
                    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="reloadgrid()">查找</a>
                </td>
            </tr>
        </table>
    </div>
    <div id="dlg" class="easyui-dialog" style="width: 400px; height: auto; padding: 10px 20px"
        data-options="closed:true,buttons:'#dlg-buttons',shadow:false">
        <form id="fm" method="post">
            <div class="fitem">
                <label>类别名称：</label>
                <input id="caname" name="caname" class="easyui-validatebox" data-options="required:true,validType:'length[1,8]'" />
                <input name="Test" id="test" type="hidden" />
                <input name="caid" id="caid" type="hidden" />
            </div>

        </form>
    </div>
    <div id="dlg-buttons">
        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" onclick="saveUser()">保存</a>
        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="javascript:$('#dlg').dialog('close')">关闭</a>
    </div>

</asp:Content>

